package test.administrator.example.com.mvptest1.list.demo;

import android.content.Context;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import test.administrator.example.com.mvptest1.list.base.BaseModel;
import test.administrator.example.com.mvptest1.list.demo.bean.PostModel;
import test.administrator.example.com.mvptest1.utils.HttpUtils;

/**
 * 作者: Dream on 16/9/24 21:09
 * QQ:510278658
 * E-mail:510278658@qq.com
 */
public class MyListModel extends BaseModel {

	public MyListModel(Context context) {
		super(context);
	}

	//获取精华列表
	public void getEssenceList(int page, int type, final HttpUtils.OnLceHttpResultListener onLceHttpResultListener) {
		Retrofit retrofit = new Retrofit.Builder()
				.baseUrl(getServerUrl())
				.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
				.addConverterFactory(GsonConverterFactory.create()).build();

		IEssenceService essenceService = retrofit.create(IEssenceService.class);
		essenceService.getLceEssenseList(page, type)
				.subscribeOn(Schedulers.io())
				.observeOn(AndroidSchedulers.mainThread())
				.subscribe(new Observer<PostModel>() {

					@Override
					public void onSubscribe(Disposable d) {

					}

					@Override
					public void onNext(PostModel postModel) {

					}

					@Override
					public void onError(Throwable e) {

					}

					@Override
					public void onComplete() {

					}
				});
	}

}
